﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SiteMaster.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Web.Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="Style/SearchForm.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <script language="javascript" type="text/javascript">
        function jScript() {
            $("#<%= txtDepartureDate.ClientID %>").datepicker({
                numberOfMonths: 2,
                minDate: 0,
                maxDate: "+1Y",
                showAnim: "show",
                showOn: "both",
                buttonImage: "/Script/jquery-ui-1.10.3.custom/css/smoothness/images/calendar.png",
                buttonImageOnly: true,
                onClose: function (selectedDate) {
                    $("#<%= txtReturnDate.ClientID %>").datepicker("option", "minDate", selectedDate);
                    var departureDate = $("#<%= txtDepartureDate.ClientID %>").datepicker('getDate');
                    var returnDate = new Date(departureDate);
                    returnDate.setDate(departureDate.getDate() + 6);
                    $("#<%= txtReturnDate.ClientID %>").datepicker("setDate", returnDate);
                }
            });

            $("#<%= txtReturnDate.ClientID %>").datepicker({
                numberOfMonths: 2,
                minDate: 0,
                maxDate: "+1Y",
                showAnim: "show",
                showOn: "both",
                buttonImage: "/Script/jquery-ui-1.10.3.custom/css/smoothness/images/calendar.png",
                buttonImageOnly: true
            });

            var lastReturnDate = '';
            $("#<%= txtDepartureDate.ClientID %>").change(function () {
                if ($(this).val() != lastReturnDate) {
                    lastValue = $(this).val();
                    setTimeout(function () { $("#<%= txtReturnDate.ClientID %>").focus() }, 0);
                }
            });
        }

        function ClearStartPoint() {
            $("#<%= hdnValueStartPoint.ClientID %>").val('');
            $("#<%= txtStartPoint.ClientID %>").val('');
        }

        function ClearEndPoint() {
            $("#<%= hdnValueEndPoint.ClientID %>").val('');
            $("#<%= txtEndPoint.ClientID %>").val('');
        }

        function OnSelectedStartPoint(source, eventArgs) {
            $("#<%= hdnValueStartPoint.ClientID %>").val(eventArgs.get_value()).trigger('change');
        }

        function OnSelectedEndPoint(source, eventArgs) {
            $("#<%= hdnValueEndPoint.ClientID %>").val(eventArgs.get_value()).trigger('change');
        }
    </script>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <script type="text/javascript" language="javascript">
                Sys.Application.add_load(jScript);
            </script>
            <div class="SearchForm">
                <div class="SearchFormHeader">
                    Flight search
                </div>
                <div class="SearchFormMain">
                    <div class="SearchFormMainItineraryType">
                        <table style="width:100%;">
                            <tr>
                                <td>
                                    <asp:RadioButton ID="rdbRoundTrip" runat="server" Text="Round trip" 
                                        GroupName="GroupItineraryType" Checked="true" AutoPostBack="true" 
                                        oncheckedchanged="rdbRoundTrip_CheckedChanged" />
                                    <asp:RadioButton ID="rdbOneWay" runat="server" Text="One way" 
                                        GroupName="GroupItineraryType" Checked="false" AutoPostBack="true" 
                                        oncheckedchanged="rdbOneWay_CheckedChanged" />
                                </td>
                                <td></td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                        </table>
                    </div>
                    <div class="SearchFormMainItinerary">
                        <table style="width:100%;">
                            <tr>
                                <td>Departure</td>
                                <td>Destination</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td>
                                    <input type="hidden" id="hdnValueStartPoint" value="" runat="server" />
                                    <asp:TextBox runat="server" ID="txtStartPoint" Width="200px" AutoComplete="off" onclick="ClearStartPoint()" />
                                    <asp:AutoCompleteExtender runat="server" BehaviorID="AutoCompleteExStartPoint" ID="AutoCompleteStartPoint"
                                        TargetControlID="txtStartPoint" ServicePath="SearchCity.asmx" ServiceMethod="GetCompletionList"
                                        MinimumPrefixLength="2" CompletionInterval="0" EnableCaching="false" CompletionSetCount="10"
                                        CompletionListCssClass="autocomplete_completionListElement" 
                                        CompletionListItemCssClass="autocomplete_listItem"
                                        CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" DelimiterCharacters=";, :"
                                        ShowOnlyCurrentWordInCompletionListItem="true" OnClientItemSelected="OnSelectedStartPoint">
                                        <Animations>
                                            <OnShow>
                                                <Sequence>
                                                    <OpacityAction Opacity="0" />
                                                    <HideAction Visible="true" />                                            
                                                    <Parallel Duration="0.2">
                                                        <FadeIn />
                                                        <Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteExStartPoint')._height" />
                                                    </Parallel>
                                                </Sequence>
                                            </OnShow>
                                            <OnHide>                                    
                                                <Sequence>
                                                    <ScriptAction Script="onHideAutocompleteStartPoint();" />
                                                    <Parallel Duration="0.2">
                                                        <FadeOut />
                                                        <Length PropertyKey="height" StartValueScript="$find('AutoCompleteExStartPoint')._height" EndValue="0" />
                                                    </Parallel>
                                                </Sequence>
                                            </OnHide>
                                        </Animations>
                                    </asp:AutoCompleteExtender>
                                </td>
                                <td>
                                    <input type="hidden" id="hdnValueEndPoint" value="" runat="server" />
                                    <asp:TextBox runat="server" ID="txtEndPoint" Width="200px" AutoComplete="off" onclick="ClearEndPoint()" />
                                    <asp:AutoCompleteExtender runat="server" BehaviorID="AutoCompleteExEndPoint" ID="AutoCompleteEndPoint"
                                        TargetControlID="txtEndPoint" ServicePath="SearchCity.asmx" ServiceMethod="GetCompletionList"
                                        MinimumPrefixLength="2" CompletionInterval="0" EnableCaching="false" CompletionSetCount="10"
                                        CompletionListCssClass="autocomplete_completionListElement" 
                                        CompletionListItemCssClass="autocomplete_listItem"
                                        CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" DelimiterCharacters=";, :"
                                        ShowOnlyCurrentWordInCompletionListItem="true" OnClientItemSelected="OnSelectedEndPoint">
                                        <Animations>
                                            <OnShow>
                                                <Sequence>
                                                    <OpacityAction Opacity="0" />
                                                    <HideAction Visible="true" />
                                                    <Parallel Duration="0.2">
                                                        <FadeIn />
                                                        <Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteExEndPoint')._height" />
                                                    </Parallel>
                                                </Sequence>
                                            </OnShow>
                                            <OnHide>
                                                <Sequence>
                                                    <Parallel Duration="0.2">
                                                        <FadeOut />
                                                        <Length PropertyKey="height" StartValueScript="$find('AutoCompleteExEndPoint')._height" EndValue="0" />
                                                    </Parallel>
                                                </Sequence>
                                            </OnHide>
                                        </Animations>
                                    </asp:AutoCompleteExtender>
                                </td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td>Departure date</td>
                                <td>
                                    <asp:Label ID="lblReturnDate" runat="server" Text="Return date"></asp:Label></td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td><asp:TextBox ID="txtDepartureDate" runat="server"></asp:TextBox></td>
                                <td><asp:TextBox ID="txtReturnDate" runat="server"></asp:TextBox></td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                        </table>
                    </div>
                    <div id="MessageBox" runat="server" class="MessageBox" visible="false">
                        <div class="Head">
                            <asp:LinkButton Style="float: right" ID="lbtClose" runat="server" OnClick="lbtClose_Click" Text="Close"></asp:LinkButton>
                            <b>
                                <asp:Label ID="lblMessageTitle" runat="server"></asp:Label></b><br>
                        </div>
                        <div class="clear">
                        </div>
                        <p>
                            <asp:Label ID="lblMessage" runat="server"></asp:Label>
                        </p>
                    </div>
                    <div class="SearchFormMainPassengers">
                        <table style="width:100%;">
                            <tr>
                                <td>
                                    Passenger</td>
                                <td>
                                    Adult:
                                    <asp:DropDownList ID="ddlAdt" runat="server">
                                        <asp:ListItem>1</asp:ListItem>
                                        <asp:ListItem>2</asp:ListItem>
                                        <asp:ListItem>3</asp:ListItem>
                                        <asp:ListItem>4</asp:ListItem>
                                        <asp:ListItem>5</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                                <td>
                                    Child:
                                    <asp:DropDownList ID="ddlChd" runat="server">
                                        <asp:ListItem>0</asp:ListItem>
                                        <asp:ListItem>1</asp:ListItem>
                                        <asp:ListItem>2</asp:ListItem>
                                        <asp:ListItem>3</asp:ListItem>
                                        <asp:ListItem>4</asp:ListItem>
                                        <asp:ListItem>5</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                                <td>
                                    Infant:
                                    <asp:DropDownList ID="ddlInf" runat="server">
                                        <asp:ListItem>0</asp:ListItem>
                                        <asp:ListItem>1</asp:ListItem>
                                        <asp:ListItem>2</asp:ListItem>
                                        <asp:ListItem>3</asp:ListItem>
                                        <asp:ListItem>4</asp:ListItem>
                                        <asp:ListItem>5</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                        </table>
                    </div>
                    
                </div>
                <div class="SearchFormFooter">
                    <asp:Button ID="btnSearch" runat="server" Text="Search" Width="120px" Height="35px" OnClick="btnSearch_Click" />
                </div>
                
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
